package com.metaverse.backend.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * com.izouma.zhumj.utils
 * 异步线程池
 * @author Pine
 * @email 771190883@qq.com
 * @date 2019/10/12
 */
public class ThreadTask {
    private static final ThreadTask threadTask = new ThreadTask();

    private ThreadTask() {
    }

    public static ThreadTask getInstance() {
        return threadTask;
    }

    /**
     * 固定线程池
     */
    private ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

    /**
     * 加入线程池执行
     *
     * @param runnable 执行线程
     */
    public void addTask(Runnable runnable) {
        executorService.execute(runnable);
    }
}
